package com.example.apiinterface.utils;


import org.apache.commons.codec.digest.DigestUtils;

/**
 * 签名计算
 */
public class SignUtil {
    public static String getSignature(String method, String url, String body, String timestamp, String nonce, String appSecret) {
        // 第一层：对请求数据进行加密
        String requestStr1 = method + url + body + appSecret;
        String signResult1 = DigestUtils.md5Hex(requestStr1);

        // 第二层加密
        String requestStr2 = appSecret + timestamp + nonce + signResult1;

        // 返回签名串
        return DigestUtils.md5Hex(requestStr2);
    }
}
